package com.changgou.service.goods.controller;

import com.changgou.goods.pojo.Sku;
import com.changgou.service.goods.service.SkuService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class SkuController {
    @Resource
    private SkuService skuService;

    @GetMapping("/sku/{spuId}")
    public List<Sku> findSkuListBySpuId(@PathVariable("spuId") String spuId) {
        Map<String, Object> searchMap = new HashMap<>();
        if (!"all".equals(spuId)) {
            searchMap.put("spuId", spuId);
        }
        searchMap.put("status", "1");
        List<Sku> skuList = skuService.findList(searchMap);
        return skuList;
    }
}
